package avortep.model;

import avortep.DBChild;
import avortep.model.type.DBType;


public class DBColumn extends DBChild {

	private DBType type;
	private DBColumnCheck check;
	private String defaultValue;
	private boolean unique;
	private boolean isNullable;	
	
	public DBColumn(String name, DBType type) {
		super(name);
		this.type = type;		
		setIsNullable(true);
		setDefaultValue(null);
		setUnique(false);	
		this.check = new DBColumnCheck("CK_"+name);
	}
	
	//getters and setters
	public DBType getType() {		
		return type;
	}
	
	public void setType(DBType type) {
		this.type = type;
	}

	
	public DBColumnCheck getCheck() {
		return check;
	}

	public void setCheck(DBColumnCheck check) {
		this.check = check;
	}
	
	public void setCheckClause(String checkClause) {
		this.check.setCheckClause(checkClause);
	}
	
	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getDefaultValue() {
		return defaultValue;
	}
	
	public void setTable(DBTable table) {
		this.setParent(table);
	}

	public DBTable getTable() {
		return (DBTable) this.getParent();
	}

	public boolean getIsNullable() {
		return isNullable;
	}

	public void setIsNullable(boolean isNullable) {
		this.isNullable = isNullable;
	}

	public boolean isUnique() {
		return unique;
	}

	public void setUnique(boolean unique) {
		this.unique = unique;
	}


	
	
}
